home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / shadowlib.lha / shadow / Examples / Source / gui.h < prev    next >
C/C++ Source or Header  |  1992-11-13  |  10KB  |  347 lines

  1. /*
  2.  * COPYRIGHT: 1992 David C. Navas                                       *
  3.  *            License granted to SwRI to modify and use as per site     *
  4.  *             license.  Further distribution license rights granted    *
  5.  *             upon receipt of agreed upon compensation.                *
  6.  *            All Other Rights Reserved by Author                       *
  7.  */
  8.  
  9. #ifndef SHADOW_GUI_H
  10. #define SHADOW_GUI_H
  11.  
  12. #include <exec/exec.h>
  13. #include <intuition/intuition.h>
  14. #include <libraries/gadtools.h>
  15. #include <shadow/watcher.h>
  16.  
  17. #include <pragmas/exec_pragmas.h>
  18. #include <pragmas/dos_pragmas.h>
  19. #include <pragmas/intuition_pragmas.h>
  20. #include <pragmas/gadtools_pragmas.h>
  21.  
  22. #include <clib/exec_protos.h>
  23. #include <clib/dos_protos.h>
  24. #include <clib/intuition_protos.h>
  25. #include <clib/gadtools_protos.h>
  26.  
  27. /*
  28.  * ==========================================================================
  29.  * =                                                                        =
  30.  * =           Class definition for the GUI process.                        =
  31.  * =                                                                        =
  32.  * ==========================================================================
  33.  */
  34. #ifndef GUIPROCESS_CLASS
  35. #define GUIPROCESS_CLASS "gui process class"
  36. #endif
  37.  
  38. #ifndef ASLPROCESS_CLASS
  39. #define ASLPROCESS_CLASS "asl process class"
  40. #endif
  41.  
  42. #ifndef GUITASK
  43. #define GUITASK "Gui Task\0"
  44. #endif
  45.  
  46. #define ATTR_GUIPROCESS "shared window port\0"
  47. struct GuiProcess {
  48.    struct MsgPort *guip_port;
  49. };
  50.  
  51. void HandleIntuiMessage(struct IntuiMessage *intui);
  52. void GUIThreadStart(void);
  53.  
  54.  
  55. /*
  56.  * ==========================================================================
  57.  * =                                                                        =
  58.  * =           Class definition for GUI type of objects.                    =
  59.  * =                                                                        =
  60.  * ==========================================================================
  61.  */
  62. #ifndef GUI_CLASS
  63. #define GUI_CLASS        "gui class"
  64. #endif
  65.  
  66. #define ATTR_GUICHILDREN   "gui children\0"
  67. #define ATTR_GUISTRUCT     "gui struct\0"
  68. struct GUIStruct {
  69.    OBJECT gui_parent;
  70.    char   *gui_moniker;
  71. };
  72.  
  73. #define ATTR_GUIOUTPUT     "gui output\0"
  74. struct OutputStruct {
  75.    OBJECT out_object;
  76.    char   *out_method;
  77. };
  78.  
  79. extern ARGUMENT_TAG REF_GuiInitMethod[];
  80.  
  81. void *GuiInitMethod(METHOD_ARGS, OBJECT parent,
  82.                                  char   *name,
  83.                                  OBJECT out_object,
  84.                                  char   *out_method);
  85. void GuiRemoveMethod(METHOD_ARGS);
  86. void GuiDestroyMethod(METHOD_ARGS);
  87.  
  88. /*
  89.  * The following are responsible for these:
  90.  *    a) Setting the focus object.
  91.  *    b) notification of state change.
  92.  */
  93.  
  94. #define METH_GUI_RESIZE  "Resize Gui Element"
  95. #define METH_GUI_FOCUS   "Grab Focus"
  96. extern ARGUMENT_TAG REF_GuiGrabFocus[];
  97. void GuiGrabFocus(METHOD_ARGS, long flag);
  98.  
  99. struct GuiIntuiHeader {
  100.     /* the Class bits correspond directly with the IDCMP Flags, except for the
  101.      * special bit LONELYMESSAGE (defined below)
  102.      */
  103.     ULONG gih_Class;
  104.  
  105.     /* the Code field is for special values like MENU number */
  106.     USHORT gih_Code;
  107.  
  108.     /* the Qualifier field is a copy of the current InputEvent's Qualifier */
  109.     USHORT gih_Qualifier;
  110.  
  111. };
  112.  
  113. struct GuiIntuiMouse {
  114.     /* when getting mouse movement reports, any event you get will have the
  115.      * the mouse coordinates in these variables.  the coordinates are relative
  116.      * to the upper-left corner of your Window (GIMMEZEROZERO notwithstanding)
  117.      */
  118.     SHORT gim_MouseX,
  119.           gim_MouseY;
  120.  
  121. };
  122.  
  123. struct GuiIntuiTime {
  124.     /* the time values are copies of the current system clock time.  Micros
  125.      * are in units of microseconds, Seconds in seconds.
  126.      */
  127.     ULONG gii_Seconds, gii_Micros;
  128.  
  129. };
  130.  
  131. struct GuiIntuiMsg {
  132.    struct GuiIntuiHeader   gii_header;
  133.  
  134. #define gii_Class          gii_header.gih_Class
  135. #define gii_Code           gii_header.gih_Code
  136. #define gii_Qualifier      gii_header.gih_Qualifier
  137.  
  138.     /* IAddress contains particular addresses for Intuition functions, like
  139.      * the pointer to the Gadget or the Screen
  140.      * This is likely to be meaningless....  Particularly when sent
  141.      *  Asynchronously.  subclassed methods should always be called!
  142.      */
  143.    APTR                    gii_IAddress;
  144.  
  145.    struct GuiIntuiMouse    gii_mouse;
  146.  
  147. #define gii_MouseX         gii_mouse.gim_MouseX
  148. #define gii_MouseY         gii_mouse.gim_MouseY
  149.  
  150.    struct GuiIntuiTime     gii_time;
  151.  
  152. #define gii_Seconds        gii_time.git_Seconds
  153. #define gii_Micros         gii_time.git_Micros
  154. };
  155.  
  156. #define METH_GUI_STATE   "Intuition update"
  157. extern ARGUMENT_TAG REF_GuiStateNotify[];
  158. void GuiStateNotify(METHOD_ARGS, struct GuiIntuiMsg *info, OBJECT window);
  159.  
  160. /*
  161.  * ==========================================================================
  162.  * =                                                                        =
  163.  * =           Class definition for window objects.                         =
  164.  * =                                                                        =
  165.  * ==========================================================================
  166.  */
  167.  
  168. #ifndef WINDOW_CLASS
  169. #define WINDOW_CLASS     "Window Class\0"
  170. #endif
  171.  
  172. #define ATTR_WINDOW     "window attributes"
  173. struct WindowObject {
  174.    struct Window *wo_window;
  175.    /*
  176.     * Should really be a pointer to a screen Object, but....
  177.     */
  178.    struct VisualInfo *wo_vi;
  179.  
  180.    /*
  181.     * Will eventually need menus here, too.
  182.     */
  183.    struct Gadget *wo_rootGadget, *wo_lastGadget;
  184.    struct WindowLocation *wo_wl;
  185.    OBJECT                wo_wlObject;
  186.    char                  *wo_localWindowName;
  187. };
  188.  
  189. struct WindowLocation {
  190.    long  wl_left,
  191.          wl_top,
  192.          wl_width,
  193.          wl_height,
  194.          wl_xInc,
  195.          wl_yInc,
  196.          wl_flags;
  197.  
  198. /*
  199.  * Internal use only all below.
  200.  */
  201.  
  202.    short wl_localLeft,
  203.          wl_localTop,
  204.          wl_localWidth,
  205.          wl_localHeight;
  206. };
  207.  
  208. /*
  209.  * Put in wl_* (not flags) for better control of window overlapping.
  210.  *
  211.  * PERCENT for top/left/width/height uses the low 16bits as a percentage
  212.  *  value from screen location.
  213.  * BORDER for width/height is used to skip an overlapping window's borders
  214.  * UNDERMOUSE for left/top to Open window with left/top as MOUSE coords.
  215.  */
  216. #define WLO_Border      0x10000
  217. #define WLO_Percent     0x20000
  218. #define WLO_UnderMouse  0x40000
  219.  
  220. /*
  221.  * wl_flags
  222.  *
  223.  * Don't check for window collisions -- used to reopen already opened and
  224.  *  -repositioned- windows.
  225.  *
  226.  * Backstore saves the position of the window off -- will reset next window
  227.  *  Open to Open to the same place.  Requires that passed WindowLocation
  228.  *  structure stay around in the wlObject that is passed to the window INIT
  229.  *  method.
  230.  * Tile[Horiz|Vert] -- better name -- Shingle? Layer?
  231.  * NoAuto -- DON'T do any auto-placement.
  232.  */
  233. #define WLO_Backstore   0x1
  234. #define WLO_TileHoriz   0x2
  235. #define WLO_TileVert    0x4
  236. #define WLO_NoAuto      0x8
  237.  
  238. /*
  239.  * Internal flags.
  240.  */
  241. #define WLO_ReTile     0x80000000
  242. #define WLO_ResetVert   0x40000000
  243. #define WLO_ResetHoriz  0x20000000
  244.  
  245. enum {WLO_Location = TAG_USER + 1};
  246.  
  247.  
  248. #define METH_WINDOW_CLOSE      METH_REMOVE
  249. #define METH_WINDOW_REFRESH    "Method window refresh"
  250. #define METH_WINDOW_PRETITLE   "Prepend this string to window title"
  251. #define METH_WINDOW_MOVE       "Move Window to position"
  252. #define METH_WINDOW_UPDATE     "Update Window default location"
  253. #define METH_GADGET_SELECT     "Method gadget select"
  254.  
  255. extern ARGUMENT_TAG REF_WinOpenMethod[];
  256.  
  257. void *WinOpenMethod(METHOD_ARGS, OBJECT parent,
  258.                                  char *name,
  259.                                  OBJECT out_object,
  260.                                  char *out_method,
  261.                                  struct TagItem *tags,
  262.                                  OBJECT wlObject);
  263. void WinCloseMethod(METHOD_ARGS);
  264. void WinDestroyMethod(METHOD_ARGS);
  265.  
  266.  
  267. /*
  268.  * ==========================================================================
  269.  * =                                                                        =
  270.  * =           Class definition for GADTOOL gadget objects.                 =
  271.  * =                                                                        =
  272.  * ==========================================================================
  273.  */
  274.  
  275. #ifndef GADGT_CLASS
  276. #define GADGT_CLASS    "Gadget GadTool Class\0"
  277. #endif
  278.  
  279. #define ATTR_GADGET   "gadget base offset\0"
  280.  
  281. struct GadgetObject {
  282.    struct Gadget *go_gadget;
  283. };
  284.  
  285. extern ARGUMENT_TAG REF_GadgTOpenMethod[], REF_GadgTChangeMethod[];
  286.  
  287. void *GadgTOpenMethod(METHOD_ARGS, OBJECT window,
  288.                                    char *name,
  289.                                    OBJECT out_object,
  290.                                    char *out_method,
  291.                                    struct NewGadget *ng,
  292.                                    long gadType,
  293.                                    struct TagItem *tags);
  294.  
  295.  
  296. #define METH_GADGET_CHANGE "Method Change gadtool attrs"
  297. void GadgTChangeMethod(METHOD_ARGS, struct TagItem *tags);
  298.  
  299. /*
  300.  * ==========================================================================
  301.  * =                                                                        =
  302.  * =           Class definition for ASL objects.                            =
  303.  * =                                                                        =
  304.  * ==========================================================================
  305.  */
  306.  
  307. #ifndef ASL_CLASS
  308. #define ASL_CLASS    "ASL Requester Class"
  309. #endif
  310.  
  311. #define ATTR_ASLREQUEST   "ASL Request ptr"
  312.  
  313. struct AslRequest {
  314.    union {
  315.       void  *uar_Requester;
  316.       struct FileRequester *uar_FileRequester;
  317.       struct FontRequester *uar_FontRequester;
  318.    }       ar_union;
  319. #define ar_Requester ar_union.uar_Requester
  320. #define ar_FileRequester ar_union.uar_FileRequester
  321. #define ar_FontRequester ar_union.uar_FontRequester
  322.    USHORT  ar_OpenFlag;
  323.    OBJECT  ar_ParentWindow;
  324.    OBJECT  ar_LocalWindow;
  325.    ULONG   ar_gadType;
  326.  
  327.    /*
  328.     * for resource tracking.
  329.     */
  330.    char *ar_FontName;
  331.    char *ar_File;
  332.    char *ar_Dir;
  333.    char *ar_OKText;
  334.    char *ar_CancelText;
  335. };
  336.  
  337. #define ASL_FLAG_BEGUN  1
  338. #define ASL_FLAG_REMOVE 2
  339.  
  340. #define METH_ASL_LAUNCH "Method Launch asl requester"
  341. #define METH_ASL_BEGIN  "Method Open Requester"
  342. #define METH_ASL_DONE   "Method Requester Closed"
  343.  
  344. BOOL InitGUISystem(void);
  345.  
  346. #endif
  347.